package cn.wolfcode.crm.service.impl;

import cn.wolfcode.crm.domain.PointBuy;
import cn.wolfcode.crm.mapper.PointBuyMapper;
import cn.wolfcode.crm.query.PointBuyQueryObject;
import cn.wolfcode.crm.service.IPointBuyService;
import cn.wolfcode.crm.util.PageResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PointBuyServiceImpl implements IPointBuyService {
    @Autowired
    private PointBuyMapper mapper;
    public void save(PointBuy entity) {
        mapper.insert(entity);
    }

    public void delete(Long id) {
        mapper.deleteByPrimaryKey(id);

    }

    public void update(PointBuy entity) {
        mapper.updateByPrimaryKey(entity);
    }

    public PointBuy get(Long id) {
        return mapper.selectByPrimaryKey(id);
    }

    public List<PointBuy> list() {
        return mapper.selectAll();
    }

    public PageResult query(PointBuyQueryObject qo) {

        int total = mapper.queryForCount(qo);
        if(total == 0){
            return new PageResult();

        }
        List<PointBuy> list = mapper.queryForList(qo);

        return new PageResult(total,list);
    }
}
